package com.chen.service;

import java.io.File;


public class FileTransferor {
	public static void changeDirectory(String filename,String oldpath,String newpath,boolean cover){   
	    if(!oldpath.equals(newpath)){   
	        File oldfile=new File(oldpath+"/"+filename);   
	        File newfile=new File(newpath+"/"+filename);   
	        if(newfile.exists()){//若在待转移目录下，已经存在待转移文件   
	            if(cover)//覆盖   
	                oldfile.renameTo(newfile);   
	            else 
	                System.out.println("在新目录下已经存在："+filename);   
	        }   
	        else{   
	            oldfile.renameTo(newfile);   
	        }   
	    }          
	} 
}
